package com.ruoyi.web.controller.teacher;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.domain.BasisImportantevents;
import com.ruoyi.service.IBasisImportanteventsService;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 重要事件Controller
 * 
 * @author wangzebing
 * @date 2025-06-26
 */
@RestController
@RequestMapping("/importantevents")
public class BasisImportanteventsController extends BaseController
{
    @Autowired
    private IBasisImportanteventsService basisImportanteventsService;

    /**
     * 查询重要事件列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BasisImportantevents basisImportantevents)
    {
        startPage();
        List<BasisImportantevents> list = basisImportanteventsService.selectBasisImportanteventsList(basisImportantevents);
        return getDataTable(list);
    }

    /**
     * 导出重要事件列表
     */
    @Log(title = "重要事件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasisImportantevents basisImportantevents)
    {
        List<BasisImportantevents> list = basisImportanteventsService.selectBasisImportanteventsList(basisImportantevents);
        ExcelUtil<BasisImportantevents> util = new ExcelUtil<BasisImportantevents>(BasisImportantevents.class);
        util.exportExcel(response, list, "重要事件数据");
    }

    /**
     * 获取重要事件详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(basisImportanteventsService.selectBasisImportanteventsById(id));
    }

    /**
     * 新增重要事件
     */
    @Log(title = "重要事件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasisImportantevents basisImportantevents)
    {
        return toAjax(basisImportanteventsService.insertBasisImportantevents(basisImportantevents));
    }

    /**
     * 修改重要事件
     */
    @Log(title = "重要事件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasisImportantevents basisImportantevents)
    {
        return toAjax(basisImportanteventsService.updateBasisImportantevents(basisImportantevents));
    }

    /**
     * 删除重要事件
     */
    @Log(title = "重要事件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(basisImportanteventsService.deleteBasisImportanteventsByIds(ids));
    }


    @GetMapping(value = "/selectBasisImportanteventsByLoadingId")
    public AjaxResult selectBasisImportanteventsByLoadingId( String loadingId)
    {
        return success(basisImportanteventsService.selectBasisImportanteventsByLoadingId(loadingId));
    }
}
